<template>
    <div class="app-container">
      <div class="filter-container">
        <el-card>
<!--          <el-input size="small" v-model="listQuery.fileName" placeholder="文件名" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />-->
          <el-form :inline="true" :model="listQuery">
            <el-form-item label="类型：">
              <el-select size="small" v-model="listQuery.qtid" placeholder="类型" clearable class="filter-item" style="width: 130px">
                <el-option v-for="item in fileTypeOptions" :key="item.qtid" :label="item.typeName" :value="item.qtid" />
              </el-select>
            </el-form-item>
            <el-form-item label="日期：">
              <el-date-picker
                size="small"
                v-model="listQuery.addingTime"
                value-format="yyyy-MM-dd"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button size="small" type="primary" icon="el-icon-search" @click="handleFilter">查询</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </div>
      <el-table
        :data="tableData"
        style="width: 100%"
        border
        size="mini">
        <el-table-column type="index" :index="pageIndex" label="序号" min-width="40" align="center"></el-table-column>
        <el-table-column prop="url" label="资料" min-width="500" align="center"></el-table-column>
<!--        <el-table-column prop="iid" label="类型" min-width="100" align="center"></el-table-column>-->
        <el-table-column prop="addingTime" label="上传时间" min-width="150" align="center">
          <template slot-scope="scope">
            <i class="el-icon-time"></i>{{scope.row.addingTime}}
          </template>
        </el-table-column>
        <el-table-column prop="operation" label="操作" min-width="150" align="center">
          <template slot-scope="scope">
<!--            <el-button v-if="scope.row.qtid === 'mp4'" type="primary" size="mini" @click="handleCat(scope.$index)">查看</el-button>-->
            <el-button type="primary" size="mini" @click="handleCat(scope.$index)">查看</el-button>
            <el-link v-if="scope.row.url" :href="scope.row.url">
              <el-button type="success" size="mini">下载</el-button>
<!--              <el-button type="success" size="mini" @click="handleDownload(scope.$index)">下载</el-button>-->
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <pagination :total="page.totalSize" :page.sync="page.pageNum" @pagination="changePage" />

    </div>
</template>
<script>
  import Pagination from '@/components/Pagination'
  import {getList,getInfo,getAllType,getType} from '@/api/material'
  export default {
    components: { Pagination },
    data() {
      return {
        tableData: [{}],
        listQuery: {
          qtid: '',
          addingTime: ''
        },
        page:{
          pageNum: 1,
          pageSize: 10,
          totalPage: 0,
          totalSize: 0
        },
        fileTypeOptions:[]
      }
    },
    created(){
      this.getList()
      this.getAllType()
    },
    methods: {
      changePage(val){
        this.page.pageNum = val
        this.getList()
      },
      getList(){
        getList({
          ...this.listQuery,
          pageNum: this.page.pageNum,
          pageSize: this.page.pageSize}).then(res => {
            this.tableData = res.data.list
            this.page = res.data.page
        })
      },
      handleCat(index){
        this.$router.push({ path: '/material/playVideo', query: { param: index }})
      },
      handleDownload(index){
        window.open(
          "http://47.96.182.33:8080/files/4028cf816dafb858016dafe2f7e80002/2c9060126ed162f0016ed3be5ed40013.pptx",
          "_blank"
        );
      },
      handleFilter(){
        this.getList()
      },
      getAllType(){
        getAllType().then(res => {
          this.fileTypeOptions = res.data
        }).catch(err => {
          this.$message.error('请求失败！')
        })
      },
    },
    computed: {
      pageIndex: function () {
        return (this.page.pageNum - 1) * this.page.pageSize + 1
      },

    },
    filters:{

    }
  }
</script>
<style scoped></style>

